package server.util;

import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import server.config.ServerConfig;
import server.db.SQL;

public class CacheTableNeuErstellen {
	
	private static Logger logger = Logger.getLogger(CacheTableNeuErstellen.class);
	
	public static void main(String[] args) {

		PropertyConfigurator.configure("log4J.cfg");
		try {
			new ServerConfig("serverConfigLocal.cfg");
			SQL.getInstance();

			try {
				PreparedStatement stmt;
				stmt = SQL.getInstance().getConPool().getConnectionFromPool().prepareStatement("SELECT id FROM `alarmierungen`");

				ResultSet rs = stmt.executeQuery();

				while (rs.next()) {

					System.out.println(rs.getInt("id"));
					if (rs.getInt("id") < 1) {
						continue;
					}
					
					SQL.getInstance().addAlarmShowTable(rs.getInt("id"));

				}
			} catch (SQLException e) {
				logger.error("SQLException", e);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	

}
